﻿using UnityEngine;
using System.Collections;

//[ExecuteInEditMode]
public class GWnd : MonoBehaviour
{

    //
    public Vector3 _ShowOnPos;
    public iTween.EaseType OnEasyType;
    public Vector3 _ShowOffPos;
    public iTween.EaseType OffEaseType;




    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }



    void OnGUI()
    {
        if (GUI.Button(new Rect(10, 10, 100, 30), "On"))
        {
            RunStart();
        }
        if (GUI.Button(new Rect(10, 50, 100, 30), "Off"))
        {
            RunEnd();
        }
    }

    /// <summary>
    /// 
    /// </summary>
    private void RunStart()
    {
        Hashtable args = new Hashtable();
        args.Add("name", "GWnd");
        args.Add("from", gameObject.transform.localPosition);
        args.Add("to", _ShowOnPos);
        args.Add("time", 0.5f);
        args.Add("onupdate", "UpdatePos");
        args.Add("easetype", OnEasyType);
        iTween.ValueTo(gameObject, args);
    }
    /// <summary>
    /// 
    /// </summary>
    private void RunEnd()
    {
        Hashtable args = new Hashtable();
        args.Add("name", "GWnd");
        args.Add("from", gameObject.transform.localPosition);
        args.Add("to", _ShowOffPos);
        args.Add("time", 0.5f);
        args.Add("onupdate", "UpdatePos");
        args.Add("easetype", OffEaseType);
        iTween.ValueTo(gameObject, args);
    }


    /// <summary>
    /// 更新位置
    /// </summary>
    void UpdatePos(Vector3 value)
    {
        gameObject.transform.localPosition = value;
    }

}
